import React from 'react';
import PropTypes from 'prop-types';
// propTypes 类型检查官网文档:https://www.npmjs.com/package/prop-types

class TestMyProps extends React.Component {
    // 对props进行类型检查
    static propTypes = {
        name: PropTypes.string.isRequired,
        sex: PropTypes.string,
        age: PropTypes.number
    }
    // 对props设置默认值
    static defaultProps = {
        sex: '男',
        age: 18
    }
    static = {}
    render() {
        let { name, sex, age } = this.props;
        return (<div>
            <span>姓名：{name}</span><br />
            <span>性别：{sex}</span><br />
            <span>年龄：{age}</span><br />
        </div>)
    }
}

export default TestMyProps;